/** CS2340 40 Jiggawatt Hard Driver Project
 *  Suk Hwan Hong
 *  Rhys Saraceni
 *  Travis Cooper
 *  Luke Stubb
 */

// $codepro.audit.disable com.instantiations.assist.eclipse.analysis.audit.rule.effectivejava.alwaysOverridetoString.alwaysOverrideToString, numericLiterals, variableShouldBeFinal
package edu.gatech.jiggawatt.office.client;


import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;

import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JLabel;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.IOException;
import java.util.List;

import javax.swing.JPasswordField;

import edu.gatech.jiggawatt.office.model.Admin;
import edu.gatech.jiggawatt.office.model.Patient;
import edu.gatech.jiggawatt.office.model.Nurse;
import edu.gatech.jiggawatt.office.model.Doctor;
import edu.gatech.jiggawatt.office.model.User;
import edu.gatech.jiggawatt.office.presenter.Presenter;

import java.util.logging.ConsoleHandler;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.XMLFormatter;

/**
 * @author 40 Jiggawatt Hard Driver
 * @version 1.0 
 */
public class Client {

	/**
	 * Field loginFrame.
	 */
	private JFrame loginFrame;

	/**
	 * Field patientFrame.
	 */
	private JFrame patientFrame;
	
	/**
	 * Field adminFrame.
	 */
	private JFrame adminFrame;
	
	/**
	 * Field nurseFrame.
	 */
	private JFrame nurseFrame;
	
	/**
	 * Field doctorFrame.
	 */
	private JFrame doctorFrame;
	
	/**
	 * Field idField.
	 */
	private JTextField idField;
	
	/**
	 * Field idLabel.
	 */
	private JLabel idLabel;
	
	/**
	 * Field pwLabel.
	 */
	private JLabel pwLabel;
	
	/**
	 * Field userList.
	 */
	private JTextArea userList;
	
	/**
	 * Field presenter.
	 */
	private Presenter presenter;
	
	/**
	 * Field serverIP.
	 */
	private String serverIP = "127.0.0.1";

	/**
	 * Field serverPort.
	 */
	private String serverPort = "12345";
	
	/**
	 * Field pwField.
	 */
	private JPasswordField pwField;
	
	/**
	 * Field ACCOUNT_LOCKED.
	 */
	/**
	 * Field DOCTOR_TYPE.
	 */
	/**
	 * Field NURSE_TYPE.
	 */
	/**
	 * Field PATIENT_TYPE.
	 */
	/**
	 * Field ADMIN_TYPE.
	 */
	private final int ADMIN_TYPE = 0, PATIENT_TYPE = 1, // $codepro.audit.disable instanceFieldNamingConvention, nonBlankFinalInstanceField
		NURSE_TYPE = 2, DOCTOR_TYPE = 3, ACCOUNT_LOCKED = 4; // $codepro.audit.disable instanceFieldNamingConvention, nonBlankFinalInstanceField
	
	/**
	 * Logger used for logging
	 */
	private static final Logger myLogger = Logger.getLogger( // $codepro.audit.disable staticFieldNamingConvention, constantNamingConvention
			"edu.gatech.jiggawatt.office.client");

	static {        
        ConsoleHandler ch = new ConsoleHandler();
        ch.setLevel(Level.ALL);
        ch.setFormatter(new XMLFormatter());
        myLogger.addHandler(ch);
        myLogger.setLevel(Level.ALL);
        myLogger.setUseParentHandlers(false);
        
        try {
            FileHandler fh = new FileHandler("clientlog.html");
            myLogger.addHandler(fh);
        } catch (SecurityException e) {
            myLogger.log(Level.SEVERE, "Security Exception creating a file handler", e);
            e.printStackTrace();
        } catch (IOException e) {
            myLogger.log(Level.SEVERE, "IO Exception creating a file handler", e);
            e.printStackTrace();
        } 
        
    }
	
	/**
	 * Launch the application.
	 * @param args String[]
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					myLogger.entering(this.getClass().getName(), 
							"Entering Main", new Object[] {});
					Client client = new Client(); // $codepro.audit.disable variableUsage
					myLogger.info("In main method");
			        myLogger.exiting(this.getClass().getName(), "Exiting Main", null);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Creates presenter and show login screen (program start up)
	 */
	public Client() {
		presenter = new Presenter(serverIP, serverPort);
		showLoginScreen();
	}

	/**
	 * shows login screen
	 */
	private void showLoginScreen() {
		loginFrame = new JFrame();
		loginFrame.setBounds(100, 100, 450, 300);
		loginFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JPanel panel = new JPanel();
		loginFrame.getContentPane().add(panel, BorderLayout.CENTER);
		panel.setLayout(null);
		
		idField = new JTextField();
		idField.setBounds(178, 87, 86, 20);
		panel.add(idField);
		idField.setColumns(10);
		
		JButton btnLogin = new JButton("Login");
		
		//Login handler
		btnLogin.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String id = idField.getText();
				String pw = new String(pwField.getPassword());
				
				//Empty case check
				if (id.length() == 0) {
					JOptionPane.showMessageDialog(null, "ID field is empty", 
							"Error", JOptionPane.ERROR_MESSAGE);
				}
				else if (pw.length() == 0) {
					JOptionPane.showMessageDialog(null, "PW field is empty", 
							"Error", JOptionPane.ERROR_MESSAGE);
				}
				//Ask presenter to check for login
				else {
					//-1 if login fails, 4 if account is locked
					//otherwise, loginSucess holds the userType
					int loginSuccess = presenter.login(id, pw);
					
					//Show appropriate screen according to the loginSuccess value
					if (loginSuccess == -1) {
						JOptionPane.showMessageDialog(null, "Login Attempt Failed", 
								"Error", JOptionPane.ERROR_MESSAGE);
					}
					else if (loginSuccess == ACCOUNT_LOCKED) {
						JOptionPane.showMessageDialog(null, 
								"Your Account is locked due to 3 consecutive miss", 
								"Error", JOptionPane.ERROR_MESSAGE);
					}
					else {
						if (loginSuccess == ADMIN_TYPE) {
							showAdminScreen(id);
						}
						else if (loginSuccess == PATIENT_TYPE) {
							showPatientScreen(id);
						}
						else if (loginSuccess == NURSE_TYPE) {
							showNurseScreen(id);
						}
						else if (loginSuccess == DOCTOR_TYPE) {
							showDoctorScreen(id);
						}
						else {
							System.out.println("SHOULD NOT SEE THIS SCREEN");
						}
						loginFrame.setVisible(false);
						loginFrame.dispose();
					}
				}
			}
		});
		
		btnLogin.setBounds(175, 149, 89, 23);
		panel.add(btnLogin);
		
		JButton btnSave = new JButton("Save");
		btnSave.setBounds(175, 180, 89, 23);
		panel.add(btnSave);
		
		JButton btnLoad = new JButton("Load");
		btnLoad.setBounds(175, 210, 89, 23);
		panel.add(btnLoad);
		
		//Save button handler
		btnSave.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JFileChooser chooser = new JFileChooser();
				int res = chooser.showDialog(null, "Save Database Data");
				if (res == JFileChooser.APPROVE_OPTION) {
				    presenter.save(chooser.getSelectedFile().getAbsolutePath());
				}
			}
		});
		
		//Load button handler
		btnLoad.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
					JFileChooser chooser = new JFileChooser();
					int res = chooser.showDialog(null, "Load Database data");
					if (res == JFileChooser.APPROVE_OPTION) {
					    presenter.load(chooser.getSelectedFile().getAbsolutePath());
					}
				}
		});
		
		idLabel = new JLabel("ID");
		idLabel.setBounds(145, 89, 16, 17);
		panel.add(idLabel);
		
		pwLabel = new JLabel("PW");
		pwLabel.setBounds(145, 117, 23, 23);
		panel.add(pwLabel);
		
		pwField = new JPasswordField();
		pwField.setBounds(178, 118, 86, 20);
		panel.add(pwField);
		
		loginFrame.setVisible(true);
	}
	
	/**
	 * Shows admin screen
	 * @param id String
	 */
	private void showAdminScreen(String id) {
		adminFrame = new JFrame();
		adminFrame.setBounds(100, 100, 450, 300);
		adminFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JPanel panel = new JPanel();
		adminFrame.getContentPane().add(panel, BorderLayout.CENTER);
		panel.setLayout(null);
		
		JLabel lbladminScreen = new JLabel("Admin logged in as : " + id);
		lbladminScreen.setBounds(10, 11, 300, 25);
		panel.add(lbladminScreen);
				
		JButton btnLogout = new JButton("Logout");
		btnLogout.setBounds(20, 47, 120, 23);
		panel.add(btnLogout);
		adminFrame.setVisible(true);
		
		JButton btnAddUser = new JButton("Add User");
		btnAddUser.setBounds(20, 80, 120, 23);
		panel.add(btnAddUser);
	
		JButton btnReadUser = new JButton("Read User");
		btnReadUser.setBounds(20, 113, 120, 23);
		panel.add(btnReadUser);
		
		JButton btnUpdateUser = new JButton("Update User");
		btnUpdateUser.setBounds(20, 146, 120, 23);
		panel.add(btnUpdateUser);
		
		JButton btnRemoveUser = new JButton("Remove User");
		btnRemoveUser.setBounds(20, 179, 120, 23);
		panel.add(btnRemoveUser);

		//Logout handler
		btnLogout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				adminFrame.setVisible(false);
				adminFrame.dispose();
				showLoginScreen();
			}
		});
		
		//Add user handler
		btnAddUser.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String[] sTypes = {"Admin", "Patient", "Nurse", "Doctor"};
				String sType = (String) JOptionPane.showInputDialog(null, 
						"Choose User Type:", "Choose User Type",
						JOptionPane.INFORMATION_MESSAGE, null,
						sTypes, sTypes[1]);
				String id = JOptionPane.showInputDialog("User ID:");
				String pw = JOptionPane.showInputDialog("User PW:");
				String firstName = JOptionPane.showInputDialog("First Name:");
				String lastName = JOptionPane.showInputDialog("Last Name:");
				
				//Create and add user according to the user input
				if (sType.equals("Admin")) {
					presenter.addUser(new Admin(id, pw, firstName, lastName));
				}
				else if (sType.equals("Patient")) {
					presenter.addUser(new Patient(id, pw, firstName, lastName));
				}
				else if (sType.equals("Nurse")) {
					presenter.addUser(new Nurse(id, pw, firstName, lastName));
				}
				else {
					presenter.addUser(new Doctor(id, pw, firstName, lastName));
				}
			}
		});
		
		userList = new JTextArea();
		userList.setBounds(160, 47, 150, 200);
		panel.add(userList);
		
		//Read user handler
		btnReadUser.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				userList.setText("");
				List<User> users = presenter.getUserList();
				
				//iterate through user list and read user to the list
				for (User e : users) {
					userList.append(e.getId() + ": ");
					if (e.getUserType() == 0) {
						userList.append("Admin\n");
					}
					else if (e.getUserType() == 1) {
						userList.append("Patient\n");
					}
					else if (e.getUserType() == 2) {
						userList.append("Nurse\n");
					}
					else {
						userList.append("Doctor\n");
					}
				}
			}
		});
		
		//Update user handler
		btnUpdateUser.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String id = JOptionPane.showInputDialog("id:");
				User user = presenter.getUser(id);
				
				if (user == null) {
					JOptionPane.showMessageDialog(null, "User CANNOT BE FOUND", 
							"Error", JOptionPane.ERROR_MESSAGE);
				}
				else {
					JOptionPane.showMessageDialog(null, 
							"User will be updated properly later");
					//presenter.updateUser(id);
				}
			}
		});
		
		//Remove User handler
		btnRemoveUser.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String id = JOptionPane.showInputDialog("id:");
			
				if (presenter.removeUser(id) == false) { // $codepro.audit.disable equalityTestWithBooleanLiteral
					JOptionPane.showMessageDialog(null, "User CANNOT BE FOUND", 
							"Error", JOptionPane.ERROR_MESSAGE);
				}
				else {
					JOptionPane.showMessageDialog(null, "User properly removed");
				}
			}
		});
		
		
	}
	
	/**
	 * Shows patient screen
	 * @param id String
	 */
	private void showPatientScreen(String id) {
		patientFrame = new JFrame();
		patientFrame.setBounds(100, 100, 450, 300);
		patientFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JPanel panel = new JPanel();
		patientFrame.getContentPane().add(panel, BorderLayout.CENTER);
		panel.setLayout(null);
		
		JLabel lblPatientScreen = new JLabel("Patient logged in as: " + id);
		lblPatientScreen.setBounds(10, 11, 300, 25);
		panel.add(lblPatientScreen);
		
		JButton btnLogout = new JButton("Logout");
		btnLogout.setBounds(20, 47, 150, 23);
		panel.add(btnLogout);
				
		JButton btnAddAppointment = new JButton("Add appoinment");
		btnAddAppointment.setBounds(20, 80, 150, 23);
		panel.add(btnAddAppointment);
		patientFrame.setVisible(true);
		
		JButton btnViewAppointment = new JButton("View appoinment");
		btnViewAppointment.setBounds(20, 113, 150, 23);
		panel.add(btnViewAppointment);
		
		JButton btnUpdateAppointment = new JButton("Update appoinment");
		btnUpdateAppointment.setBounds(20, 146, 150, 23);
		panel.add(btnUpdateAppointment);
		
		JButton btnRemoveAppointment = new JButton("Remove appoinment");
		btnRemoveAppointment.setBounds(20, 179, 150, 23);
		panel.add(btnRemoveAppointment);
		
		//Logout handler
		btnLogout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				patientFrame.setVisible(false);
				patientFrame.dispose();
				showLoginScreen();
			}
		});
		
		//Add appointment handler
		btnAddAppointment.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "Appointment will be properly added");
				//presenter.addAppointment(new Appointment(1, "Date", "Reason", "Doctor"), id);
			}
		});
		
		//View appointment handler		
		btnViewAppointment.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "Appointment will be viewed");
				//presenter.viewAppointment(id);
			}
		});
		
		//Update appointment handler
		btnUpdateAppointment.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "Appointment will be updated");
				//presenter.updateAppointment(new Appointment(1, "Data", "Reason", "Doctor"), id);
			}
		});
			
		//Remove appointment handler
		btnRemoveAppointment.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "Appointment will be removed");
				//presenter.removeAppointment(appNum, id);
			}
		});
	}
	
	/**
	 * shows nurse screen
	 * @param id String
	 */
	private void showNurseScreen(String id) {
		nurseFrame = new JFrame();
		nurseFrame.setBounds(100, 100, 450, 300);
		nurseFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JPanel panel = new JPanel();
		nurseFrame.getContentPane().add(panel, BorderLayout.CENTER);
		panel.setLayout(null);
		
		JLabel lblnurseScreen = new JLabel("Nurse logged in as: " + id);
		lblnurseScreen.setBounds(10, 11, 300, 25);
		panel.add(lblnurseScreen);
		
		JButton btnLogout = new JButton("Logout");
		btnLogout.setBounds(20, 47, 89, 23);
		panel.add(btnLogout);
		nurseFrame.setVisible(true);
		
		JButton btnFindPatient = new JButton("Find Patients");
		btnFindPatient.setBounds(20, 80, 190, 23);
		panel.add(btnFindPatient);
		
		JButton btnAddTR = new JButton("Add Treatment Record");
		btnAddTR.setBounds(20, 113, 190, 23);
		panel.add(btnAddTR);
		
		JButton btnViewTR = new JButton("View Treatment Record");
		btnViewTR.setBounds(20, 146, 190, 23);
		panel.add(btnViewTR);
		
		JButton btnUpdateTR = new JButton("Update Treatment Record");
		btnUpdateTR.setBounds(20, 179, 190, 23);
		panel.add(btnUpdateTR);
		
		JButton btnRemoveTR = new JButton("Remove Treatment Record");
		btnRemoveTR.setBounds(20, 212, 190, 23);
		panel.add(btnRemoveTR);
		
		JButton btnInvoice = new JButton("Create Invoice");
		btnInvoice.setBounds(220, 80, 190, 23);
		panel.add(btnInvoice);
			
		//Logout handler
		btnLogout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				nurseFrame.setVisible(false);
				nurseFrame.dispose();
				showLoginScreen();
			}
		});
		
		//Find patient handler
		btnFindPatient.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String firstName = JOptionPane.showInputDialog("Patient's first name: ");
				String lastName = JOptionPane.showInputDialog("Patient's last name: ");
				Patient patient = presenter.getPatient(firstName + " " + lastName);
				
				//cannot find patient
				if (patient == null) {
					JOptionPane.showMessageDialog(null, "Patient NOT FOUND", 
							"Error", JOptionPane.ERROR_MESSAGE);
				}
				//show patient found
				else {
					JOptionPane.showMessageDialog(null, 
							"Patient found: " + patient.getId());
				}
			}
		});
		
		//Add Treatment Record handler
		btnAddTR.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "TR will be added");
				//presenter.addTR(new TreatmentRecord(), id);
			}
		});
		
		//View Treatment Record handler
		btnViewTR.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "TR will be viewed");
				//presenter.viewTR(id);
			}
		});
		
		//Update Treatment Record handler
		btnUpdateTR.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "TR will be updated");
				//presenter.updateTR(id);
			}
		});
		
		//Remove Treatment Record handler
		btnRemoveTR.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "TR will be removed");
				//presenter.removeTR(new TreatmentRecord(), id);
			}
		});
		
		//Invoice handler
		btnInvoice.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "Invoice will be created");
				//presenter.createInvoice(id);
			}
		});
		}
	
	/**
	 * Method showDoctorScreen.
	 * @param id String
	 */
	private void showDoctorScreen(String id) {
		doctorFrame = new JFrame();
		doctorFrame.setBounds(100, 100, 450, 300);
		doctorFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		JPanel panel = new JPanel();
		doctorFrame.getContentPane().add(panel, BorderLayout.CENTER);
		panel.setLayout(null);
		
		JLabel lbldoctorScreen = new JLabel("Doctor logged in as: " + id);
		lbldoctorScreen.setBounds(10, 11, 300, 25);
		panel.add(lbldoctorScreen);
		
		JButton btnLogout = new JButton("Logout");
		btnLogout.setBounds(20, 47, 89, 23);
		panel.add(btnLogout);
		doctorFrame.setVisible(true);
		
		JButton btnFindPatient = new JButton("Find Patients");
		btnFindPatient.setBounds(20, 80, 190, 23);
		panel.add(btnFindPatient);
		
		JButton btnAddTR = new JButton("Add Treatment Record");
		btnAddTR.setBounds(20, 113, 190, 23);
		panel.add(btnAddTR);
		
		JButton btnViewTR = new JButton("View Treatment Record");
		btnViewTR.setBounds(20, 146, 190, 23);
		panel.add(btnViewTR);
		
		JButton btnUpdateTR = new JButton("Update Treatment Record");
		btnUpdateTR.setBounds(20, 179, 190, 23);
		panel.add(btnUpdateTR);
		
		JButton btnRemoveTR = new JButton("Remove Treatment Record");
		btnRemoveTR.setBounds(20, 212, 190, 23);
		panel.add(btnRemoveTR);
		
		JButton btnAddOrder = new JButton("Add Doctor's Order");
		btnAddOrder.setBounds(220, 113, 190, 23);
		panel.add(btnAddOrder);
		
		JButton btnViewOrder = new JButton("View Doctor's Order");
		btnViewOrder.setBounds(220, 146, 190, 23);
		panel.add(btnViewOrder);
		
		JButton btnUpdateOrder = new JButton("Update Doctor's Order");
		btnUpdateOrder.setBounds(220, 179, 190, 23);
		panel.add(btnUpdateOrder);
		
		JButton btnRemoveOrder = new JButton("Remove Doctor's Order");
		btnRemoveOrder.setBounds(220, 212, 190, 23);
		panel.add(btnRemoveOrder);
		
		//Logout handler
		btnLogout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				doctorFrame.setVisible(false);
				doctorFrame.dispose();
				showLoginScreen();
			}
		});
		
		//Find Patient handler
		btnFindPatient.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String firstName = JOptionPane.showInputDialog("Patient's first name: ");
				String lastName = JOptionPane.showInputDialog("Patient's last name: ");
				Patient patient = presenter.getPatient(firstName + " " + lastName);
				
				//Patient not found
				if (patient == null) {
					JOptionPane.showMessageDialog(null, "Patient NOT FOUND", 
							"Error", JOptionPane.ERROR_MESSAGE);
				}
				//Show patient found
				else {
					JOptionPane.showMessageDialog(null, 
							"Patient found: " + patient.getId());
				}
			}
		});
		
		//Add TR handler
		btnAddTR.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "TR will be added");
				//presenter.addTR(new TreatmentRecord(), id);
			}
		});
		
		//View TR handler
		btnViewTR.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "TR will be viewed");
				//presenter.viewTR(id);
			}
		});
		
		//update TR handler
		btnUpdateTR.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "TR will be updated");
				//presenter.updatewTR(new TreatmentRecord(), id);
			}
		});
		
		//Remove TR handler
		btnRemoveTR.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "TR will be removed");
				//presenter.removeTR(TRnum, id);
			}
		});
		
		//Add Order handler
		btnAddOrder.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "Order will be added");
				//presenter.addOrder(new DoctorsOrder(), id);
			}
		});
		
		//View Order handler
		btnViewOrder.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "Order will be viewed");
				//presenter.viewOrder(id);
			}
		});
		
		//Update order handler
		btnUpdateOrder.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "Order will be updated");
				//presenter.updateOrder(new DoctorsOrder(), id);
			}
		});
		
		//Remove order handler
		btnRemoveOrder.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				JOptionPane.showMessageDialog(null, "Order will be removed");
				//presenter.removeOrder(orderNum, id);
			}
		});
	}
}
